import { Effect, ImmerReducer } from "@/.umi/plugin-dva/connect"
import { getAddress } from "@/service/address"
export interface IListA{
    name: string,
    tel: string,
    province: number,
    city: string,
    county: string,
    addressDetail: string,
    isDefault: string,
    userid: string,
    addressid: string,
}
export interface IAddress{
    namespace: 'address',
    state:{
        addressList:Array<IListA>
    },
    effects:{
        getAddressW: Effect
    },
    reducers:{
        UPDATA_ADDRESS: ImmerReducer

    }
}
const GetAddressList:IAddress = {
    namespace: 'address',
    state: {
        addressList: []
    },
    effects:{
        *getAddressW({payload},{call,put}){
            const res = yield call(getAddress,payload)
            yield put({
                type: 'UPDATA_ADDRESS',
                payload:res.data
            })
        }
    },
    reducers:{
        UPDATA_ADDRESS(state,action){
            state.addressList = action.payload
            // console.log(state.adminList,123);
        }
    }
}

export default GetAddressList